﻿using System.Collections.Generic;
using CivilRegistry.ControlledModel.Repository;

namespace CivilRegistry.ControlledModel
{
    /// <summary>
    /// The family object.
    /// </summary>
    public partial class Family
    {
        /// <summary>
        /// Holds the <see cref="FamilyRepository"/> instance.
        /// </summary>
        static FamilyRepository repository = new FamilyRepository();

        /// <summary>
        /// Finds the <see cref="Family"/> by Id.
        /// </summary>
        /// <param name="id">The id of the <see cref="Family"/>.</param>
        /// <returns>Found <see cref="Family"/> object, null if not found.</returns>
        public static Family FindById(int id)
        {
            return repository.FindBy(family => family.FamilyId == id);
        }

        /// <summary>
        /// Finds all <see cref="Family"/>s.
        /// </summary>
        /// <returns>Found <see cref="Family"/> objects, empty if none are found.</returns>
        public static List<Family> FindAll()
        {
            return repository.FindAll();
        }

        /// <summary>
        /// To save the changes made to this object.
        /// </summary>
        /// <returns>Saved <see cref="Family"/> object.</returns>
        public Family SaveChanges()
        {
            return repository.Update(this);
        }
    }
}